package top.wu2020.lazy.ws.chat.controller;

import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import org.wu.framework.web.spring.EasyController;
import org.springframework.web.bind.annotation.*;
import org.wu.framework.web.response.Result;
import org.wu.framework.web.response.ResultFactory;
import org.springframework.beans.factory.annotation.Autowired;
import jakarta.annotation.Resource;
import top.wu2020.lazy.ws.chat.application.command.user.*;
import top.wu2020.lazy.ws.chat.domain.model.user.User;
import top.wu2020.lazy.ws.chat.application.UserApplication;
import top.wu2020.lazy.ws.chat.application.dto.UserDTO;
import java.util.List;
import org.wu.framework.lazy.orm.database.lambda.domain.LazyPage;
/**
 * describe user 
 *
 * @author Jia wei Wu
 * @date 2024/05/24 08:52 晚上
 * @see org.wu.framework.lazy.orm.core.persistence.reverse.lazy.ddd.DefaultDDDLazyController 
 **/
@Tag(name = "提供者")
@EasyController("/user")
public class UserProvider  {

    @Resource
    private UserApplication userApplication;

    /**
     * describe 新增
     *
     * @param userStoryCommand 新增     
     * @return {@link Result<User>} 新增后领域对象     
     
     * @author Jia wei Wu
     * @date 2024/05/24 08:52 晚上
     **/

    @Operation(summary = "新增")
    @PostMapping("/story")
    public Result<User> story(@RequestBody UserStoryCommand userStoryCommand){
        return userApplication.story(userStoryCommand);
    }
    /**
     * describe 批量新增
     *
     * @param userStoryCommandList 批量新增     
     * @return {@link Result<List<User>>} 新增后领域对象集合     
     
     * @author Jia wei Wu
     * @date 2024/05/24 08:52 晚上
     **/

    @Operation(summary = "批量新增")
    @PostMapping("/batchStory")
    public Result<List<User>> batchStory(@RequestBody List<UserStoryCommand> userStoryCommandList){
        return userApplication.batchStory(userStoryCommandList);
    }
    /**
     * describe 更新
     *
     * @param userUpdateCommand 更新     
     * @return {@link Result<User>} 领域对象     
     
     * @author Jia wei Wu
     * @date 2024/05/24 08:52 晚上
     **/

    @Operation(summary = "更新")
    @PutMapping("/updateOne")
    public Result<User> updateOne(@RequestBody UserUpdateCommand userUpdateCommand){
        return userApplication.updateOne(userUpdateCommand);
    }
    /**
     * describe 查询单个
     *
     * @param userQueryOneCommand 查询单个     
     * @return {@link Result<UserDTO>} DTO对象     
     
     * @author Jia wei Wu
     * @date 2024/05/24 08:52 晚上
     **/

    @Operation(summary = "查询单个")
    @GetMapping("/findOne")
    public Result<UserDTO> findOne(@ModelAttribute UserQueryOneCommand userQueryOneCommand){
        return userApplication.findOne(userQueryOneCommand);
    }

    /**
     * 获取随机用户
     * @return
     */
    @Operation(summary = "获取随机用户")
    @GetMapping("/getRandomUser")
    public Result<UserDTO> getRandomUser(){
        return userApplication.getRandomUser();
    }

    /**
     * 登录
     * @return
     */
    @Operation(summary = "登录")
    @PostMapping("/login")
    public Result<UserDTO> login(@RequestBody UserLoginCommand userLoginCommand){
        return userApplication.login(userLoginCommand);
    }
    /**
     * describe 查询多个
     *
     * @param userQueryListCommand 查询多个     
     * @return {@link Result<List<UserDTO>>} DTO对象     
     
     * @author Jia wei Wu
     * @date 2024/05/24 08:52 晚上
     **/

    @Operation(summary = "查询多个")
    @GetMapping("/findList")
    public Result<List<UserDTO>> findList(@ModelAttribute UserQueryListCommand userQueryListCommand){
        return userApplication.findList(userQueryListCommand);
    }
    /**
     * describe 分页查询多个
     *
     * @param userQueryListCommand 分页查询多个     
     * @return {@link Result<LazyPage<UserDTO>>} 分页DTO对象     
     
     * @author Jia wei Wu
     * @date 2024/05/24 08:52 晚上
     **/

    @Operation(summary = "分页查询多个")
    @GetMapping("/findPage")
    public Result<LazyPage<UserDTO>> findPage(@Parameter(description ="分页大小") @RequestParam(defaultValue = "10", value = "size") int size,
                           @Parameter(description ="当前页数") @RequestParam(defaultValue = "1", value = "current") int current,@ModelAttribute UserQueryListCommand userQueryListCommand){
        return userApplication.findPage(size,current,userQueryListCommand);
    }
    /**
     * describe 删除
     *
     * @param userRemoveCommand 删除     
     * @return {@link Result<User>}      
     
     * @author Jia wei Wu
     * @date 2024/05/24 08:52 晚上
     **/

    @Operation(summary = "删除")
    @DeleteMapping("/remove")
    public Result<User> remove(@ModelAttribute UserRemoveCommand userRemoveCommand){
        return userApplication.remove(userRemoveCommand);
    }
}